<?php


namespace Tbf\Bundle\RouteBundle\Matcher;


use Symfony\Component\HttpFoundation\Request;
use Tbf\Bundle\RouteBundle\Matcher\MatcherInterface;
use Tbf\Component\Http\ServeFile\ServeFile;

class FileMapMatcher implements MatcherInterface{
    protected $url;
    protected $file_path;
    function __construct($url,$file_path){
        $this->file_path = $file_path;
        $this->url = $url;
    }
    function match(Request $request){
        if ($request->getPathInfo()!==$this->url){
            return null;
        }
        list($resp,$err)  = ServeFile::serviceSymfony($request,$this->file_path);
        if ($err!==null){
            return null;
        }
        return $resp;
    }
}